package org.matrix.base
{

	public class Matrix6D extends Matrix5D
	{
		public function Matrix6D(depth:uint){super(depth); 	d6Lenght  = d5Lenght * depth;}
		
		override public function get dimensions():uint		{return 5}
		
		internal var d6Lenght:uint;
		protected var d6Index:uint;
		internal var d6Dirty:Boolean;
		internal var d6:Vector.<Vector.<Vector.<Vector.<Vector.<Vector.<Number>>>>>>;
		override protected function init():void
		{
			d6 = new Vector.<Vector.<Vector.<Vector.<Vector.<Vector.<Number>>>>>>(depth,true);
			for (var i:uint; i < depth; i++)
			{
				super.init();
				d6[i] = d5;
			}
		}
		
		override public function getElement( ... keys:Array):Number				{return d6[keys.unshift()][keys.unshift()][keys.unshift()][keys.unshift()][keys.unshift()][keys.unshift()]}
		override public function setElement(value:Number, ... keys:Array):void	{d6[keys.unshift()][keys.unshift()][keys.unshift()][keys.unshift()][keys.unshift()][keys.unshift()] = value}
		
		override public function get index():uint	{return d6Index * d5Lenght + super.index}
		
		override protected function validate():void
		{
			if (d5Dirty)
			{
				d5 = d6[d6Index];
				d5Dirty = false;
				d4Dirty = true;
			}
			return super.validate();
		}
		
		protected function d7Inc(recursive:Boolean = false):void
		{
			if (recursive)
				d6Index = 0;
			else
				throw new Error('')
		}
		final override protected function d6Inc(recursive:Boolean = false):void
		{
			if (++ d6Index == depth)
				d6Inc(d6Dirty = true);
			if (recursive)
				d5Index = 0;
		}
	}
}
